Skip to content

feat(codegen): render metamodel vocabulary reference from shared Mustache templates in every port - #670

Merged
dmealing merged 7 commits into
mainfrom
fm/mo-130-metamodel-docs-mustache
Nov 28, 2026
Merged

dmealing merged 7 commits into
mainfrom
fm/mo-130-metamodel-docs-mustache

Conversation

@dmealing

@dmealing dmealing commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • The vocabulary reference pages (INDEX.md, providers.md, and types/<family>.md) now render from the shared templates/metamodel/ Mustache set. Each port builds the page data from its registry vocabulary manifest and embedded provider definitions.
  • C#, Java, Kotlin, Python and Rust gain a metamodel-docs generator. Every port is checked against fixtures/metamodel-docs/ (page data in data/, expected bytes in expected/). A project can override a page with its own templates/metamodel/<page>.mustache.
  • TypeScript: @metaobjectsdev/metadata drops renderMetamodelDocs, renderCoreMetamodelDocs, buildMetamodelProvenance and MetamodelProvenance. It exports coreMetamodelDocsPages() and buildMetamodelDocsPages() instead, and codegen-ts renders them. An ejected metamodel-docs generator that calls the removed functions must be re-ejected. The TypeScript output changes in one place: index.lookup now lists its owning provider and the provider of its @fields.
Validation

Risk Assessment

✅ Low: The latest fix round fixes the Python owned-copy subDir bug correctly. build_owned now converts subDir to the sub_dir keyword and passes template_root, and the new test compares the owned output against the packaged output under ref/. All six template copies are byte-identical to templates/metamodel/, the corpus carries the port-neutral header, and the Rust, C#, Java and Kotlin generators are consistent thin shells over the shared page data.

Testing

Drove the three most user-visible paths. TypeScript builder and Python CLI both reproduce the 23 expected pages byte for byte, with the Python run executed through the real metaobjects gen in a disposable project. The ejected Python copy honours subDir per the focused CLI test that passed. Rust, Java, Kotlin and C# pages were not rendered live in this turn; their byte-match is covered only by the configured affected-lane run that already passed. No source changed, the worktree is clean, and scratch output was removed.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
TypeScript metamodel-docs pages render byte-identical to fixtures/metamodel-docs/expected (local builder, synthetic: registry vocabulary) ✅ pass live bun scratch render of coreMetamodelDocsPages()+renderDocPage, then diff -r vs fixtures/metamodel-docs/expected: 23 files, no diff
Python metaobjects gen with a metamodel-docs target writes the 23 vocabulary pages matching the corpus (local CLI, disposable project) ✅ pass live Scratch project with metaobjects.config.yaml targets.docs.generators=[metamodel-docs]; metaobjects gen exit 0, wrote 23 files under generated/metamodel/; diff vs expected empty
Ejected/packaged Python metamodel-docs honours the subDir option (adversarial: option moves pages, not silently ignored) ✅ pass live pytest tests/codegen/test_eject.py -k sub_dir -> 1 passed; drives main(['gen']) in disposable packaged and owned projects with subDir: ref; direct generator run with sub_dir='ref' lands pages under re…
Evidence: TS render diff vs corpus (live)
pages: 23
TS BYTE-IDENTICAL (diff -r empty; 23 files)
Evidence: Python metaobjects gen CLI diff vs corpus (live)
metaobjects gen: wrote 23 file(s) across 1 target(s). exit=0
CLI BYTE-IDENTICAL (diff -r empty)
Evidence: Python ejected subDir focused test
1 passed, 12 deselected

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 4 infos
  • ⚠️ server/rust/metaobjects-codegen/src/metamodel_docs.rs:31 - The Rust generator names its output-directory option dir. Every other port names the same option subDir: TypeScript metamodelDocsFile({ subDir }), Java and Kotlin arg subDir, Python registry option subDir (generator_registry.py:551), and C# init property SubDir. docs/ports/rust.md and the test the_dir_option_moves_the_pages_and_a_project_template_wins (tests/metamodel_docs.rs:106) record dir. It is the first option any shipped Rust generator takes, so renaming it after release becomes a breaking config change. Recommendation: rename it to subDir now, unless the Rust option-naming convention is meant to differ.
  • ⚠️ server/python/src/metaobjects/codegen/generators/metamodel_docs_generator.py:35 - Simplification: _provider_descriptions(template_root) lets a project override the provider descriptions with its own metamodel/provider-descriptions.json. The generator docstring (line 11) and docs/ports/python.md describe this. No other port does it. TypeScript reads coreProviderDescriptions(), C# ReadDescriptions() reads only the embedded resource, Java reads only the classpath resource, and Rust reads only shipped_provider_descriptions(). The intent asks for one shared Mustache set with data pinned to the corpus. The changelog promises only page-template overrides, and no requirement needs a per-project override of the description data. Recommendation: remove the project lookup and always read the bundled file, as the other ports do.
  • ℹ️ server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsEmitter.java:49 - MetamodelDocsEmitter.render(Page, Provider) has no callers. Its Javadoc says "the corpus test builds from pinned inputs", but MetamodelDocsCorpusTest calls only MetamodelDocsPages.build() and MetamodelDocsEmitter.emit(&#34;&#34;, null). Remove the method, or point emit at it so one render path exists.
  • ℹ️ docs/ports/csharp.md:357 - Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.

🔧 Fix applied.
4 infos still open:

  • ℹ️ docs/ports/csharp.md:357 - Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.
  • ℹ️ server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23 - Applied inline. The class Javadoc and the eject note named the override argument templateDir. The generator actually reads metamodelTemplateDir (ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments to metamodelTemplateDir. The code is unchanged.
  • ℹ️ docs/ports/rust.md:81 - Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator except service-routes. Both statements became false when this change added metamodel-docs, which takes subDir and is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to name metamodel-docs and its subDir option, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.
  • ℹ️ templates/metamodel/index.md.mustache:3 - Every page in the shared template set starts with the header 'Regenerate with: meta gen (the metamodel-docs generator, metamodelDocsFile())'. The affected templates are templates/metamodel/index.md.mustache:3, providers.md.mustache:3 and type-page.md.mustache:3. C#, Java, Kotlin, Python and Rust now write these pages byte for byte, so the generated docs in those ports tell users to run the Node meta gen and a TypeScript factory. Those ports actually regenerate with dotnet meta gen, mvn metaobjects:generate, metaobjects gen and cargo meta gen. Recommended fix: use port-neutral wording, for example 'Regenerate with your port's gen command (the metamodel-docs generator)'. That wording changes the corpus bytes in fixtures/metamodel-docs/expected/ and the codegen-ts header test (codegen-ts/test/metamodel-docs.test.ts:75). The change needs a regen and a sync, so the author should decide whether the byte-identical pages may carry port-neutral text.

🔧 Fix applied.
5 issues (1 warning, 4 infos) still open:

  • ℹ️ docs/ports/csharp.md:357 - Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.
  • ℹ️ server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23 - Applied inline. The class Javadoc and the eject note named the override argument templateDir. The generator actually reads metamodelTemplateDir (ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments to metamodelTemplateDir. The code is unchanged.
  • ℹ️ docs/ports/rust.md:81 - Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator except service-routes. Both statements became false when this change added metamodel-docs, which takes subDir and is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to name metamodel-docs and its subDir option, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.
  • ⚠️ server/python/src/metaobjects/codegen/generators/metamodel_docs_generator.py:74 - The factory metamodel_docs_generator(ctx) reads options.get(&#34;sub_dir&#34;, ...). The two Python paths fill ctx.options differently. The packaged path (cli.py:900-904) runs resolve_options and passes snake_case keys, so sub_dir is found. The owned path is what metaobjects eject metamodel-docs produces: build_owned (cli.py:889, eject.py:382-404) passes a one-argument context factory the options "as written", so the key is camelCase subDir. Concrete sequence: eject metamodel-docs, then wire the copy as {name: &#34;codegen.generators.metamodel_docs:metamodel_docs_generator&#34;, options: {subDir: &#34;ref&#34;}}. The pages still land under metamodel/, with no error. The registry option and docs/ports/python.md both document subDir, so the owned copy breaks a documented setting without warning. The Python test calls only the constructor (MetamodelDocsGenerator(sub_dir=...)), so it covers neither path. Fix: read both spellings, e.g. options.get(&#34;sub_dir&#34;, options.get(&#34;subDir&#34;, DEFAULT_SUB_DIR)). Also add a test that builds the generator through the owned module:symbol path with {subDir: ...}. This bug comes from the original commit, not from a fix round.
  • ℹ️ server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts:38 - Applied inline. The ALL_PROVIDER_DEFINITIONS doc comment said "The order is irrelevant". The new page builder records the first definition that declares an attr on a type as that attr's provider and default. The C#, Java, Python and Rust ports copy this walk order for that reason; Rust DEFINITION_SOURCES says "the order is part of the contract". I rewrote the comment to say the order is part of the contract and every port walks it. This is a comment-only change.

🔧 Fix applied.
📝 4 wording or comment-placement notes left for the author (no fix round spent):

  • ℹ️ docs/ports/csharp.md:357 - Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.
  • ℹ️ server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23 - Applied inline. The class Javadoc and the eject note named the override argument templateDir. The generator actually reads metamodelTemplateDir (ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments to metamodelTemplateDir. The code is unchanged.
  • ℹ️ docs/ports/rust.md:81 - Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator except service-routes. Both statements became false when this change added metamodel-docs, which takes subDir and is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to name metamodel-docs and its subDir option, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.
  • ℹ️ server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts:38 - Applied inline. The ALL_PROVIDER_DEFINITIONS doc comment said "The order is irrelevant". The new page builder records the first definition that declares an attr on a type as that attr's provider and default. The C#, Java, Python and Rust ports copy this walk order for that reason; Rust DEFINITION_SOURCES says "the order is part of the contract". I rewrote the comment to say the order is part of the contract and every port walks it. This is a comment-only change.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
TypeScript metamodel-docs pages render byte-identical to fixtures/metamodel-docs/expected (local builder, synthetic: registry vocabulary) ✅ pass live bun scratch render of coreMetamodelDocsPages()+renderDocPage, then diff -r vs fixtures/metamodel-docs/expected: 23 files, no diff
Python metaobjects gen with a metamodel-docs target writes the 23 vocabulary pages matching the corpus (local CLI, disposable project) ✅ pass live Scratch project with metaobjects.config.yaml targets.docs.generators=[metamodel-docs]; metaobjects gen exit 0, wrote 23 files under generated/metamodel/; diff vs expected empty
Ejected/packaged Python metamodel-docs honours the subDir option (adversarial: option moves pages, not silently ignored) ✅ pass live pytest tests/codegen/test_eject.py -k sub_dir -> 1 passed; drives main(['gen']) in disposable packaged and owned projects with subDir: ref; direct generator run with sub_dir='ref' lands pages under re…
  • scripts/ci-local.sh --affected --strict-toolchains
  • Scratch render of coreMetamodelDocsPages() through renderDocPage with templates/metamodel, diffed with diff -r against fixtures/metamodel-docs/expected (TypeScript reference, live, 23 files)
  • metaobjects gen (Python console script, server/python/.venv) in a disposable project under $DEV_SCRATCH with targets.docs.generators: [metamodel-docs]; exit 0, 23 files written under generated/metamodel/, diffed against fixtures/metamodel-docs/expected (live CLI)
  • Python generator direct render with sub_dir='' and sub_dir='ref' via python -I in scratch; default output byte-identical to corpus, subDir output lands under ref/
  • pytest -q tests/codegen/test_eject.py -k sub_dir (test_an_ejected_metamodel_docs_copy_honours_its_sub_dir_option; runs the CLI main() in disposable projects, both packaged and ejected, subDir=ref) -> 1 passed
  • Checked templates/metamodel/index.md.mustache header wording in expected/INDEX.md: port-neutral ('Regenerate with your port's gen command'), matching the round-3 fix
  • Rust option name is dir in server/rust/metaobjects-codegen/src/metamodel_docs.rs, reading OPTION_SUB_DIR; not driven live (cargo not run in this turn)
  • Baseline scripts/ci-local.sh --affected --strict-toolchains (already passed at target commit, not re-run; no source changed in this turn)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

no-mistakes: 1 run (review took three fix rounds before approval).

…tache templates in every port

The metamodel reference pages (INDEX.md, providers.md, types/<family>.md) were
about 600 lines of TypeScript string builders and existed only in TypeScript.
They are now one template set, templates/metamodel/, rendered over page data
each port builds from its own registry vocabulary manifest and its embedded
provider definitions (the manifest is provider-blind, so ownership and
defaults come from spec/metamodel), plus a shared provider-descriptions.json.

- TypeScript: buildMetamodelDocsPages / coreMetamodelDocsPages replace
  renderMetamodelDocs and buildMetamodelProvenance; metamodelDocsFile()
  renders the pages and takes a project template override.
- C#, Java, Kotlin, Python and Rust gain a metamodel-docs generator; the
  generator registry manifest lists every port.
- fixtures/metamodel-docs gains data/ (each page's template data); every
  port's suite holds its data and its bytes to the corpus.
- sync-doc-templates.sh ships the metamodel group to every port, and the
  doc-template drift gate covers the new copies.
- Fix: index.lookup now names its owning provider; the index definition was
  missing from the provenance list (two corpus pages and the site reference
  change).
@dmealing
dmealing merged commit 85e399c into main Nov 28, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-130-metamodel-docs-mustache branch November 28, 2026 06:15
dmealing added a commit that referenced this pull request Nov 28, 2026
…Node (#671)

* feat(codegen): record each generated file's source node in C#, Java and Python manifests

After a write run, the hash manifest entry of a per-object file now names its
generator and the node's resolution key ({hash, generatedBy, sourceNode}, after
the JVM's generator/outputDir), as TypeScript already did, so a docs view built
from any of these ports lists each node's generated files. A whole-model file
keeps the plain hash. A shared 'provenance' vector in
fixtures/codegen-skip-conformance/manifests.json holds TypeScript, C#, Java and
Python to the same entries.

* no-mistakes(review): Stamp provenance in remaining per-object generators

* no-mistakes(document): Docs for C#/Java/Python provenance already updated on branch; one wording fix.

* no-mistakes(test): Stop identifier renaming in explorer bundle build

* feat(java): build the docs view and write the model explorer on the JVM, with no Node

The JVM builds the port-neutral docs view from its loaded model (DocsView), byte for byte
what TypeScript builds for every fixtures/explorer-conformance case, gated in the metadata
suite. A docs-site generator (DocsSiteGenerator, registered in the Java and Kotlin
registries, eject-exempt like TypeScript's) writes explorer.json, the shared explorer app,
explorer-model.js and explorer-stamp.js, and lists each node's generated files from the
hash manifest's provenance. Kotlin runs the same class, and its suite gates every corpus
case through its own registry. MetaEndpoint gains the /_meta/docs helpers (body, ETag,
If-None-Match), mounted by the host as /_meta is.

Needs the HashManifest.loadProvenance API from #669.

* fix(ci): clear stale unpacked workspace crates before the Rust publish dry-run

cargo publish --workspace unpacks its overlay-registry dependencies into a
per-checkout directory and never re-unpacks while the version is unchanged,
so the self-hosted runner verified metaobjects-codegen against a
metaobjects-1.3.0 unpacked before metamodel_docs existed. Main has been red on
the rust lane since #670 for this reason; the crate itself packages correctly.

* fix(java): keep the explorer data scripts out of codegen-base's layout, and hold docs-site to the inert line

The model and stamp scripts move beside the docs view serializer
(com.metaobjects.docsview.ExplorerModelScript), so codegen-base types no line
breaks (LayoutRatchetTest). The codegen-noop inert tests hold docs-site to the
line TypeScript's rules-inert test draws: the explorer documents every node, so
only its data payload may differ, and only by the new nodes and members.

* no-mistakes(review): apply reviewer inline fixes

* no-mistakes(review): Build JVM docs-site file lists from the run's output

* no-mistakes(review): apply reviewer inline fixes

* no-mistakes(review): List other executions' files in the JVM docs site

* no-mistakes(review): Re-run skip when manifest loses a file

* no-mistakes(document): Stale docs-view claim fixed; Java/Kotlin now build explorer.json
dmealing added a commit that referenced this pull request Nov 28, 2026
* feat(codegen): record each generated file's source node in C#, Java and Python manifests

After a write run, the hash manifest entry of a per-object file now names its
generator and the node's resolution key ({hash, generatedBy, sourceNode}, after
the JVM's generator/outputDir), as TypeScript already did, so a docs view built
from any of these ports lists each node's generated files. A whole-model file
keeps the plain hash. A shared 'provenance' vector in
fixtures/codegen-skip-conformance/manifests.json holds TypeScript, C#, Java and
Python to the same entries.

* no-mistakes(review): Stamp provenance in remaining per-object generators

* no-mistakes(document): Docs for C#/Java/Python provenance already updated on branch; one wording fix.

* no-mistakes(test): Stop identifier renaming in explorer bundle build

* feat(java): build the docs view and write the model explorer on the JVM, with no Node

The JVM builds the port-neutral docs view from its loaded model (DocsView), byte for byte
what TypeScript builds for every fixtures/explorer-conformance case, gated in the metadata
suite. A docs-site generator (DocsSiteGenerator, registered in the Java and Kotlin
registries, eject-exempt like TypeScript's) writes explorer.json, the shared explorer app,
explorer-model.js and explorer-stamp.js, and lists each node's generated files from the
hash manifest's provenance. Kotlin runs the same class, and its suite gates every corpus
case through its own registry. MetaEndpoint gains the /_meta/docs helpers (body, ETag,
If-None-Match), mounted by the host as /_meta is.

Needs the HashManifest.loadProvenance API from #669.

* fix(ci): clear stale unpacked workspace crates before the Rust publish dry-run

cargo publish --workspace unpacks its overlay-registry dependencies into a
per-checkout directory and never re-unpacks while the version is unchanged,
so the self-hosted runner verified metaobjects-codegen against a
metaobjects-1.3.0 unpacked before metamodel_docs existed. Main has been red on
the rust lane since #670 for this reason; the crate itself packages correctly.

* fix(java): keep the explorer data scripts out of codegen-base's layout, and hold docs-site to the inert line

The model and stamp scripts move beside the docs view serializer
(com.metaobjects.docsview.ExplorerModelScript), so codegen-base types no line
breaks (LayoutRatchetTest). The codegen-noop inert tests hold docs-site to the
line TypeScript's rules-inert test draws: the explorer documents every node, so
only its data payload may differ, and only by the new nodes and members.

* no-mistakes(review): apply reviewer inline fixes

* no-mistakes(review): Build JVM docs-site file lists from the run's output

* no-mistakes(review): apply reviewer inline fixes

* no-mistakes(review): List other executions' files in the JVM docs site

* no-mistakes(review): Re-run skip when manifest loses a file

* no-mistakes(document): Stale docs-view claim fixed; Java/Kotlin now build explorer.json

* feat(docs-site): build the model explorer in C# and Python without Node

Each port builds the port-neutral docs view from its loaded model
(MetaObjects.DocsView, metaobjects.docs_view), byte-identical to TypeScript
for every fixtures/explorer-conformance case and gated in each suite. A
docs-site generator in both registries writes explorer.json, the shared
explorer app, explorer-model.js and explorer-stamp.js; it runs after every
other generator and lists this run's files over the committed manifest's,
so verify --codegen renders what gen wrote. MetaEndpoint.MetaDocs (C#) and
meta_docs (Python) serve the same view at /_meta/docs with a strong ETag.
C# and Python provenance now records the generator's registry name.

* no-mistakes(review): Match verify docs-site render to gen; pin ETags

* no-mistakes(review): Run docs-site targets last; carry plan provenance

* no-mistakes(review): Carry only files the orphan sweep keeps

* no-mistakes(review): apply reviewer inline fixes

* no-mistakes(review): Treat an empty run file list as unknown

* no-mistakes(review): Keep empty run file lists known, as TypeScript

* no-mistakes(document): Docs: C# and Python explorer now documented
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant